package com.miyake.dsp.otdr;

public class OtdrSetting {
	private FiberNode entryPoint;
	private double frequency;
	private double distanceRange;
	private double wavelength;
	
	public OtdrSetting(double wavelength, double distance) {
		this.wavelength = wavelength;
		this.distanceRange = distance;		
	}
	
	public OtdrSetting(double frequency, double wavelength, double distance) {
		this.frequency = frequency;
		this.wavelength = wavelength;
		this.distanceRange = distance;
	}

	public FiberNode getEntryPoint() {
		return entryPoint;
	}

	public void setEntryPoint(FiberNode entryPoint) {
		this.entryPoint = entryPoint;
	}

	public double getFrequency() {
		return frequency;
	}

	public void setFrequency(double frequency) {
		this.frequency = frequency;
	}

	public double getDistanceRange() {
		return distanceRange;
	}

	public void setDistanceRange(double distanceRange) {
		this.distanceRange = distanceRange;
	}

	public double getWavelength() {
		return wavelength;
	}

	public void setWavelength(double wavelength) {
		this.wavelength = wavelength;
	}
	
	public double[] getTrace() {
		double res = 1.0/this.frequency * 3e8;
		double[] ret = this.entryPoint.getImpulseResponse(1000.0, res);
		int point = (int)(this.distanceRange*1000 / res / 1.5);
		double[] tmp = new double[point];
		for (int i = 0; i < tmp.length; i++) {
			if (i < ret.length) {
				tmp[i] = ret[i];
			}
			else {
				tmp[i] = 0;
			}
		}
		                        
		return tmp;
	}
	
}
